package com.taotao.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

/**
 * @author wangjin
 * @title: IndexController
 * @projectName sw-gateway
 * @description:
 * @date 2022/1/21 9:09
 */
@RestController
@RequestMapping("/")
/*@CrossOrigin*/
public class IndexController {

    @Value("${server.port}")
    private String serverPort;

    @RequestMapping("/getMayikt")
    public String getMayikt() {
        return "getMayikt" + serverPort;
    }

    @RequestMapping("/getUser")
    public Map<String, String> getUser() {
        /*HttpServletResponse resp = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
        resp.setHeader("Access-Control-Allow-Origin", "*");*/
        HashMap<String, String> result = new HashMap<>();
        result.put("code", "200");
        result.put("msg", "ok");
        return result;
    }
}
